home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 2 / ads / a-teioed < prev    next >
Text File  |  1996-02-12  |  6KB  |  165 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                  A D A . T E X T _ I O . E D I T I N G                   --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.2 $                              --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18.  
  19. package Ada.Text_IO.Editing is
  20.  
  21.    type Picture is private;
  22.  
  23.    function Valid
  24.      (Pic_String      : in String;
  25.       Blank_When_Zero : in Boolean := False)
  26.       return            Boolean;
  27.  
  28.    function To_Picture
  29.      (Pic_String      : in String;
  30.       Blank_When_Zero : in Boolean := False)
  31.       return            Picture;
  32.  
  33.    function Pic_String      (Pic : in Picture) return String;
  34.    function Blank_When_Zero (Pic : in Picture) return Boolean;
  35.  
  36.    Max_Picture_Length : constant := 64;
  37.  
  38.    Picture_Error : exception;
  39.  
  40.    Default_Currency   : constant String    := "$";
  41.    Default_Fill       : constant Character := ' ';
  42.    Default_Separator  : constant Character := ',';
  43.    Default_Radix_Mark : constant Character := '.';
  44.  
  45.    generic
  46.       type Num is delta <> digits <>;
  47.       Default_Currency   : in String := Text_IO.Editing.Default_Currency;
  48.       Default_Fill       : in Character := Text_IO.Editing.Default_Fill;
  49.       Default_Separator  : in Character := Text_IO.Editing.Default_Separator;
  50.       Default_Radix_Mark : in Character := Text_IO.Editing.Default_Radix_Mark;
  51.  
  52.    package Decimal_Output is
  53.  
  54.       function Length
  55.         (Pic      : in Picture;
  56.          Currency : in String := Default_Currency)
  57.          return     Natural;
  58.  
  59.       function Valid
  60.         (Item     : Num;
  61.          Pic      : in Picture;
  62.          Currency : in String := Default_Currency)
  63.          return     Boolean;
  64.  
  65.       function Image
  66.         (Item       : Num;
  67.          Pic        : in Picture;
  68.          Currency   : in String    := Default_Currency;
  69.          Fill       : in Character := Default_Fill;
  70.          Separator  : in Character := Default_Separator;
  71.          Radix_Mark : in Character := Default_Radix_Mark)
  72.          return       String;
  73.  
  74.       procedure Put
  75.         (File       : in File_Type;
  76.          Item       : Num;
  77.          Pic        : in Picture;
  78.          Currency   : in String    := Default_Currency;
  79.          Fill       : in Character := Default_Fill;
  80.          Separator  : in Character := Default_Separator;
  81.          Radix_Mark : in Character := Default_Radix_Mark);
  82.  
  83.       procedure Put
  84.         (Item       : Num;
  85.          Pic        : in Picture;
  86.          Currency   : in String    := Default_Currency;
  87.          Fill       : in Character := Default_Fill;
  88.          Separator  : in Character := Default_Separator;
  89.          Radix_Mark : in Character := Default_Radix_Mark);
  90.  
  91.       procedure Put
  92.         (To         : out String;
  93.          Item       : Num;
  94.          Pic        : in Picture;
  95.          Currency   : in String    := Default_Currency;
  96.          Fill       : in Character := Default_Fill;
  97.          Separator  : in Character := Default_Separator;
  98.          Radix_Mark : in Character := Default_Radix_Mark);
  99.  
  100.    end Decimal_Output;
  101.  
  102. private
  103.  
  104.    MAX_PICSIZE      : constant := 50;
  105.    MAX_MONEYSIZE    : constant := 10;
  106.    Invalid_Position : constant := -1;
  107.  
  108.    subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
  109.  
  110.    type Picture_Record (Length : Pic_Index := 0) is record
  111.       Expanded : String (1 .. Length);
  112.    end record;
  113.  
  114.    type Format_Record is record
  115.       --  "in"
  116.       Picture              : Picture_Record;
  117.       --  "in out"
  118.       Blank_When_Zero      : Boolean;
  119.       --  "out" components:
  120.       Star_Fill            : Boolean := False;
  121.       Radix_Position       : Integer := Invalid_Position;
  122.       Sign_Position,
  123.         Second_Sign        : Integer := Invalid_Position;
  124.       Start_Float,
  125.         End_Float          : Integer := Invalid_Position;
  126.       Start_Currency,
  127.         End_Currency       : Integer := Invalid_Position;
  128.       Max_Leading_Digits   : Integer := 0;
  129.       Max_Trailing_Digits  : Integer := 0;
  130.       Max_Currency_Digits  : Integer := 0;
  131.       Floater              : Character := '!';
  132.       --  Initialized to illegal value
  133.    end record;
  134.  
  135.    type Picture is record
  136.       Contents : Format_Record;
  137.    end record;
  138.  
  139.    type Number_Attributes is record
  140.       Negative : Boolean := False;
  141.       Has_Fraction : Boolean := False;
  142.       Start_Of_Int, End_Of_Int, Start_Of_Fraction, End_Of_Fraction : Integer
  143.          := Invalid_Position;    -- invalid value
  144.    end record;
  145.  
  146.    function Parse_Number_String (Str : String) return Number_Attributes;
  147.    --  assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
  148.    --  trailing blanks...)
  149.  
  150.    procedure Precalculate (Pic : in out Format_Record);
  151.    --  Precalculates fields from the user supplied data
  152.  
  153.    function Format_Number (Pic                 : Format_Record;
  154.                            Number              : String;
  155.                            Currency_Symbol     : String;
  156.                            Fill_Character      : Character;
  157.                            Separator_Character : Character;
  158.                            Radix_Point         : Character)
  159.                            return String;
  160.    --  Formats number according to Pic
  161.  
  162.    function Expand (Picture : in String) return String;
  163.  
  164. end Ada.Text_IO.Editing;
  165.